using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using net_work.Data.Entity.Hmw;

namespace net_work.Config.DataBaseConfig.Hmw;

/// <summary>
/// 作业题目实体配置类
/// </summary>
public class HomeworkQuestionEntityTypeConfiguration : IEntityTypeConfiguration<HomeworkQuestion>
{
    public void Configure(EntityTypeBuilder<HomeworkQuestion> builder)
    {
        builder.ToTable("hmw_hmw_ques");

        builder.HasKey(hq => hq.Id);

        // 配置字段名映射
        builder.Property(hq => hq.Id).HasColumnName("hmw_ques_id");
        builder.Property(hq => hq.BankQuestionId).HasColumnName("bank_ques_id").IsRequired();
        builder.Property(hq => hq.HomeworkId).HasColumnName("hmw_id").IsRequired();

        builder.Property(hq => hq.CreatedBy).HasColumnName("create_by").IsRequired().HasMaxLength(64);
        builder.Property(hq => hq.CreatedTime).HasColumnName("create_time").IsRequired();
        builder.Property(hq => hq.UpdatedBy).HasColumnName("update_by").IsRequired().HasMaxLength(64);
        builder.Property(hq => hq.UpdatedTime).HasColumnName("update_time").IsRequired();
        builder.Property(hq => hq.Remark).HasColumnName("remark").HasMaxLength(256);
        builder.Property(hq => hq.DelFlag).HasColumnName("del_flag").HasDefaultValue('0');
    }
}